import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)
export default new Vuex.Store({
    state: {
        // 用户信息
        userInfo: {
            userId: '',
            name: '',
            token: '',
            idType: ''
        },
        // 是否登录
        isLogin: false,
        menuList: [],
        map: {
            map: null,
            layers: {},
            select: {
                curClickFeature: null, //当前点击的
                layer: null // 当前要素所在图层
            },
            editOverlays: []
        }
    },

    mutations: {
        updateParams(state, arr) {
            // 变更状态
            if (arr[1] instanceof Array) {
                state[arr[0]] = arr[1]
            } else if (typeof arr[1] === 'object') {
                for (var key in arr[1]) {
                    state[arr[0]][key] = arr[1][key]
                }
            } else {
                state[arr[0]] = arr[1]
            }
        }
    },
    actions: {},
    modules: {}
})
